﻿using ConsoleApp2.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    public class Dbinit:DropCreateDatabaseIfModelChanges<Admin>
    {
        protected override void Seed(Admin context)
        {
            
            var class1 = new Class
            {
                ClassName="计应4班",
                StudentNum=38
            };
            var class2 = new Class
            {
                ClassName = "电商3班",
                StudentNum = 33
            };
            context.Classes.Add(class1);
            context.Classes.Add(class2);
            context.SaveChanges();

            var teacher1 = new Teacher
            {
                ClassId = class1.Id,
                TeacherName = "老胡"
            };

            var teacher2 = new Teacher
            {
                ClassId = class2.Id,
                TeacherName = "老庞"
            };

            context.Teachers.Add(teacher1);
            context.Teachers.Add(teacher2);
            context.SaveChanges();

            var Student1 = new Student
            {
                ClassId=class1.Id,
                TeacherId=teacher1.Id,
                StudentName = "小小章",
                Age = 19,
                Sex = "男"
            };

            var Student2 = new Student
            {
                ClassId = class2.Id,
                TeacherId = teacher2.Id,
                StudentName = "大壮",
                Age = 19,
                Sex = "女"
            };
            context.Students.Add(Student1);
            context.Students.Add(Student2);
            context.SaveChanges();


            base.Seed(context);
        }
    }
}
